version: '3'

services:
  mongo:
    image: mongo
    restart: always
    volumes:
      - mongo-data:/data/db
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USER}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD}
      - GIGACHAT_TOKEN=${GIGACHAT_TOKEN}
      - BOT_TOKEN=${BOT_TOKEN}
    
  mongo-express:
    image: mongo-express
    restart: always
    environment:
      - ME_CONFIG_MONGODB_SERVER=mongo
      - ME_CONFIG_MONGODB_PORT=27017
      - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
      - ME_CONFIG_MONGODB_AUTH_DATABASE=admin
      - ME_CONFIG_MONGODB_AUTH_USERNAME=${MONGO_ROOT_USER}
      - ME_CONFIG_MONGODB_AUTH_PASSWORD=${MONGO_ROOT_PASSWORD}
      - ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_LOGIN}
      - ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD}
    depends_on:
      - mongo
    ports:
      - "8889:8081"

  app:
    build: ./app
    restart: always
    environment:
      - MONGO_ROOT_USER=${MONGO_ROOT_USER}
      - MONGO_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD}
      - BOT_TOKEN=${BOT_TOKEN}
      - GIGACHAT_TOKEN=${GIGACHAT_TOKEN}
    volumes:
      - ./app:/usr/src/app
    ports:
      - "1111:3333"
    depends_on:
      - mongo
      - mongo-express

volumes:
  mongo-data:
